package top.bug.blog.controller.front;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.bug.blog.annotation.RateLimit;
import top.bug.blog.common.Result;
import top.bug.blog.entity.po.Category;
import top.bug.blog.service.CategoryService;

import javax.annotation.Resource;
import java.util.List;

import static top.bug.blog.enums.RateLimitEnum.QUERY_LIMIT;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 前台-分类模块
 */
@Api(tags = "分类管理模块")
@RestController("FrontCategoryController")
@RequestMapping("/api/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    @GetMapping("/list")
    @ApiOperation("获取状态正常的分类集合")
    @RateLimit(strategyEnum = QUERY_LIMIT)
    public Result<List<Category>> list() {
        return Result.success(categoryService.getAllEnableCategory());
    }
}